n=int(input())
ls=[]
i= int(0)
for i in range(1,n):
	if i%7!=0 and i%10!=7:
		ls.append(i)
print(ls)
b=len(ls)
total = 0
for c in range(0,b):
	total+=pow(ls[c], 2)
print(total)